﻿/// <reference path="../Scripts/_references.js" />
$(document).ready(function () {

    var ProcessMessage = $('#ProcessMessage');
    var ProcessFilter = $('#ProcessFilter');
    ProcessMessage.hide();
    ProcessFilter.hide();
    $.ajaxSetup({
        beforeSend: function () {
            // show gif here, eg:
            ProcessMessage.fadeIn();
            ProcessFilter.fadeIn();
        },
        complete: function () {
            // hide gif here, eg:
            ProcessMessage.fadeOut();
            ProcessFilter.fadeOut();
        },
        error: function (jqXHR, exception) {
            if (jqXHR.status === 0) {
                alert('Not connect.\n Verify Network.');
            }
            else if (jqXHR.status == 404) {
                alert('Requested page not found. [404]');
            }
            else if (jqXHR.status == 403) {
                alert('Session expired. [403]');
            }
            else if (jqXHR.status == 500) {
                alert('Internal Server Error [500].');
            }
            else if (exception === 'parsererror') {
                alert('Requested JSON parse failed.');
            }
            else if (exception === 'timeout') {
                alert('Time out error.');
            }
            else if (exception === 'abort') {
                alert('Ajax request aborted.');
            }
            else {
                alert('Uncaught Error.\n' + jqXHR.responseText);
            }
        }
    });

    var pathname = window.location.pathname;
    var shortpath = pathname.substring(0, 7);

    //$('body').css('display', 'none');
    //$('body').fadeIn(1000);

    switch (pathname) {
        case '/':
            $('#liHome').addClass('selected');         
            break;
        case '/Admin':
            $('#liAdmin').addClass('selected');            
            break;
        case '/Aposta':
            $('#liAposta').addClass('selected');
            break;
        case '/Classificacao':
            $('#liClassificacao').addClass('selected');
            break;
        case '/Estatistica':
            $('#liEstatisticas').addClass('selected');
            break;
        case '/Home/About':
            $('#liAbout').addClass('selected');
            break;
        case '/Home/Contact':
            $('#liContact').addClass('selected');
            break;
        case '/Registo':
            $('#liRegisto').addClass('selected');
            break;
        default:
            if (shortpath == '/Aposta') {
                $('#liAposta').addClass('selected');
                break;
            }
            //            if (shortpath == '/Admin') {
            //                $('#liAdmin').addClass('selected');
            //                break;
            //            }
            //            $('#liHome').addClass('selected');
            break;
    };

});